class SoundNoticeScene extends CoolScene
{
	public constructor() 
	{
		super();
		this.init();
	}
	private m_board:egret.Bitmap;
	private m_Callback:Function;
	private m_Obj:egret.DisplayObjectContainer;
	private m_effectId:number;
	public setCallback(callback:Function, obj:egret.DisplayObjectContainer)
	{
		this.m_Callback = callback;
		this.m_Obj = obj;
	}
	private init()
	{
		this.initBg();
		this.initText();
		this.initBtn();
	}
	public playEffect()
	{
		
		//let effectHash = DataManager.getInstance().getGameHttpData().m_levels[nowLevel].m_prompt.m_soundHash;
		//this.m_effectId =  SoundEngine.getInstance().playEffect(effectHash);
	}
	public stopEffect()
	{
		SoundEngine.getInstance().stopEffect(this.m_effectId);
	}

	private initBg()
	{
		let bg = this.createBitmapByName("blackbg");
		bg.alpha = 0.7;
		this.addChild(bg);
		bg.touchEnabled = true;//截取事件
		let board = this.createBitmapByName("tishi_k");
		board.anchorOffsetX = board.width / 2;
		board.anchorOffsetY = board.height / 2;
		board.x = this.width / 2;
		board.y = this.height / 2;
		this.addChild(board);
		this.m_board = board;
		let title = this.createBitmapByName("tishibiaoti");
		title.anchorOffsetX = title.width / 2;
		title.anchorOffsetY = title.height / 3;
		title.x = this.width / 2;
		title.y = this.height / 2 - board.height / 24 * 11;
		this.addChild(title);
	}
	private initText()
	{
		let text = new egret.TextField();
		text.text = "是否开启声音？"
		text.textAlign = egret.HorizontalAlign.CENTER;
		text.verticalAlign = egret.VerticalAlign.MIDDLE;
		text.size = 26;
		text.textColor = 0xaa5a34;
		text.fontFamily = "FangSong";
		if(text.width > this.m_board.width / 6 * 5)
		{
			text.width = this.m_board.width / 6 * 5;
			text.height = this.m_board.height / 3;
			text.textAlign = egret.HorizontalAlign.LEFT;
		}

		text.x = this.width / 2;
		text.y = this.height / 2 - this.m_board.width / 30;
		text.anchorOffsetX = text.width / 2;
		text.anchorOffsetY = text.height / 2;
		//text.background = true;
		//text.backgroundColor = 0x000000;
		this.addChild(text);
	}

	private initBtn()
	{
		let startBtn = this.createBtnByName("ensure",this.clickStartEnsure,this);
		startBtn.x = this.width / 2 - startBtn.width / 3 * 2;
		startBtn.y = this.height / 2 + startBtn.height * 1.3;
		this.addChild(startBtn);

		let cancelBtn = this.createBtnByName("cancel",this.clickStartCancel,this);
		cancelBtn.x = this.width / 2 + cancelBtn.width / 3 * 2;
		cancelBtn.y = this.height / 2 + cancelBtn.height * 1.3;
		this.addChild(cancelBtn);
	}
	private clickStartEnsure(event:egret.Event)
	{
		let callback = this.m_Callback.bind(this.m_Obj);
		callback();
	}
	private clickStartCancel(event:egret.Event)
	{
		SoundEngine.getInstance().setCanPlayMusic(false);
		let callback = this.m_Callback.bind(this.m_Obj);
		callback();
	}
}